<?php
/* @var $this \yii\web\View */
/* @var $dataProvider */
?>
    <div class="row">
        <div class="box">
            <?= \backend\components\grid\MyGridView::widget([
                'dataProvider' => $dataProvider,
                'topButtonTemplate' => '',
                'columns' => [
                    [
                        'attribute' => 'service',
                        'content' => function ($model) {
                            return \yii\helpers\Html::encode($model->service);
                        }
                    ],
                    'admin_user_id',
                    [
                        'attribute' => 'ip',
                        'content' => function ($model) {
                            return \yii\bootstrap\Html::tag('a', long2ip($model->ip), [
                                'class' => 'ip',
                                'data-toggle' => 'popover',
                                'data-placement' => 'top',
                                'data-trigger' => 'manual'
                            ]);
                        }
                    ],
                    'method',
                    'status_code',
                    'success',
                    'create_time',
                    [
                        'attribute' => 'params',
                        'content' => function ($model) {
//                            $params = htmlspecialchars($model->params, ENT_HTML5);
                            $params = $model->params;
                            return \backend\components\widgets\PopoverFull::widget([
                                'content' => \yii\bootstrap\Html::encode($params),
                                'popoverContent' => $params,
                                'width' => '400px',
                            ]);
                        }
                    ]
                ]
            ]); ?>
        </div>
    </div>
<?php
$url = \yii\helpers\Url::toRoute('/public/ip');
$js = <<<JS
$('.ip').hover(function(){
    if (!$(this).data('content')) {
        var ip = $(this).text();
        var that = this;
        $.get('{$url}?ip='+ip,function(data){
            $(that).attr('data-content',data);
            $(that).popover('toggle');
        })
    } else {
        $(this).popover('toggle');
    }
})

// $('.params').popover()
JS;
/*function getIpLocation(element){
    var ip = $(this).text();
    var this = element;
    $.get('{$url}?ip='+ip,function(data){
        $(this).
    })
}
$('.ip').each(function(){
    var ip = $(this).text();
    $(this).data('content',function() {
        $.get('{$url}?ip='+ip,function(data){
            return data;
        })
    })
})*/
$this->registerJs($js);
